using System;
using System.Data;
using System.Collections;
using istIUniDB;

namespace Shraga.BLL
{
	public class CandidatesList : ArrayList
	{

		#region Properties
		
		public DataTable Names
		{
			get
			{
				return LoadNames();
			}
		}

		#endregion

		#region Constructors

		public CandidatesList()
		: base()		
		{}
		
		public CandidatesList(String CandidateIds)		
		: base()
		{
			foreach (String Id in CandidateIds.Split(new char[] {','}))
			{
				this.Add(Convert.ToInt32(Id));	
			}
		}

		#endregion		

		#region Public CandidatesList Methods	

		public override int Add(object value)
		{
			return base.Add (Convert.ToInt32(value));
		}

		public override string ToString()
		{
			String Ids = new String(' ',0);
			foreach (int Id in this)
			{
				if (Ids != "") Ids += ",";
				Ids += Id.ToString();
			}
			return Ids;
		}


		#endregion

		#region Private Methodes

		private DataTable LoadNames()
		{
			// Gets all the users available as recipients
			return (UniDBSingleton.Instance().UniDB.RunSQLReturnDataTable(
						"select Id_number as id, first_name as first, last_name as last " +
						" from pratim where id_number in (" + ToString() + ")"));			
		}

		#endregion
	}
}